package com.zhangmeng.service.impl;

import com.zhangmeng.service.Connection;
import com.zhangmeng.service.Message;
import com.zhangmeng.service.Request;

/**
 * @author zm
 * @date 2025/2/22 15:46
 * @version: 1.0
 */
public class RequestImpl implements Request {

    private Connection connection;

//    private byte[] data;

    private Message message;

    @Override
    public Connection GetConnection() {
        return this.connection;
    }

    public Message getMessage() {
        return message;
    }

    public void setMessage(Message message) {
        this.message = message;
    }

    public RequestImpl(Connection connection, Message message) {
        this.connection = connection;
        this.message = message;
    }

    //使用message 代替 data
    //    public RequestImpl(Connection connection, byte[] data) {
//        this.connection = connection;
//        this.data = data;
//    }

    @Override
    public byte[] GetData() {
        return this.message.GetData();
    }

    public int GetMsgID() {
        if (this.message != null) {
            return this.message.GetMsgId();
        }
        return -1;
    }
}
